package graphics;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.swing.JButton;

import res.Resources;

/**
 * 
 * @author sthankan
 *
 */
public class NumberButton extends JButton {
	private final int number;
	
	private final BufferedImage img;

	public NumberButton(int no) throws IOException {
		super();
		this.number = no;
		this.img = createImage();
	}
	
	private BufferedImage createImage() throws IOException {
		return Resources.getCroppedImage(this.number);
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		Graphics2D g2d = (Graphics2D) g;
		g2d.drawImage(this.img, 0, 0, getWidth(), getHeight(), null);
	}
	
	public int getNumber() {
		return number;
	}
}
